package pure.ui 
{
	import pure.ui.core.ToggleButton;
	import pure.ui.skins.ISkin;
	import pure.ui.skins.SkinColor;
	import pure.ui.skins.SelectableSkin;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	/**
	 * 复选按钮
	 * @author Des
	 * <皮肤种类> ---- SelectableSkin
	 * 
	 */
	
public class CheckBox extends ToggleButton 
{
	public function CheckBox(x:Number = 0, y:Number = 0, size:Point = null, skin:ISkin = null, hasLabel:Boolean = true) 
	{
		super(x, y, size, skin, hasLabel );
		
	}
	
	
	protected var ____changeObserver:Function;	// 选中状态改变回调方法
	
	
	
	/**
	 * 观察选中状态变化
	 * @param changeObserver		回调方法
	 **/
	public function setObserverChange(changeObserver:Function):void
	{
		____changeObserver = changeObserver;
	}
	
	/**
	 * 毁灭
	 */
	override public function destroy():void
	{
		super.destroy();
		____changeObserver = null;
	}
	
	

	
	
	/* ----------------------------------------------------    private    ----------------------------------------------------*/
	
	
	
	

	/**
	 * 缺省皮肤
	 * @param fillColor			颜色
	 * @param isSelected			是否选中状态
	 **/
	override protected function _drawSelectedFlag(fillColor:uint,isSelected:Boolean):void
	{
		_drawNoSkin(fillColor, 1,1);
		if (isSelected) 
		{
			this.graphics.lineStyle(5);
			this.graphics.moveTo(6 - this._width * 0.5, this._height * 0.5 - 6);
			this.graphics.lineTo(this._width * 0.5 - 6, 6 - this._height * 0.5);
			this.graphics.moveTo(this._width * 0.5 - 6, this._height * 0.5 - 6);
			this.graphics.lineTo(6 - this._width * 0.5, 6 - this._height * 0.5 );
		}
	}
	
	/**
	 * 改变选择状态
	 **/
	override protected function _setSelectState():void
	{
		this.selected = !this.selected;
		if (____changeObserver != null) 
		{
			____changeObserver();
		}
	}
	
	/**
	 * 绘制
	 */
	override protected function _draw():void
	{
		_selectView(SkinColor.CheckBox_OVER, SkinColor.CheckBox_OUT, SkinColor.CheckBox_SELECTED_OVER, SkinColor.CheckBox_SELECTED_OUT);
		super._draw();
	}
}

}